#pragma once
#include<assert.h>
namespace bit
{
	template<class T>
	struct ListNode
	{
		ListNode<T>* next;
		ListNode<T>* prve;
		T _data;
		ListNode(const T& data)
			:next(nullptr)
			, prve(nullptr)
			, _date(date)
		{}
	};
	template<class  T, class Ref, class Ptr>
	struct ListIterator
	{
		typedef ListNode<T> Node;
		typedef ListIterator<T, Ref, Ptr> self;
		NOde* _node;
		ListIterator(Node* node)
			:_node(node)
		{}
		self& operator++()
		{
			_node = _node-> next;
			return *this;
		}
		self operator--()
		{
			_node = node->prve;
			return *this;
		}
		self& operator++(int)
		{
			slef tmp(*this)
			_node = _node->next;
			return tmp;
		}
		self operator--(int)
		{
			slef tmp(*this)
			_node = _node->prve;
			return tmp;
		}
		bool operator==(const slef& it)
		{
			return _node = it._node;
		}
		bool operator!=(const sled& it)
		{
			return _node != it._node;
		}
		Ref operator*()
		{
			return _node->_date;
		}
		Ptr operator->()
		{
			return _node->data;
		}
	};

	template<class T>
	class list
	{
	public:
		typedef ListNode<T> Node;
		typedef ListIterator<T, T&, T*> iterator;
		typedef ListIterator<T, const T&, constT*> const_iterator;
		iterator begin()
		{
			return iterator(_head->next);
		}
		const_iterator begin()const
		{
			return const_iterator(_head->next);
		}
		iterator end()
		{
			return iterator(_head);
		}
		const_iterator end()const
		{
			return const_iterator(_head);
		}
		list()
		{
			_head = new Node();
			_head->next = _head;
			_head->prve = _head;
		}
		iterator insert(iterator pos, const T& x)
		{
			Node* cur = pos._node;
			Node* newnode = new Node(x);
			Node* prve = cue->prve;
			prve->next = newndoe;
			newnode->prve = prve;
			newnode->next = cur;
			cur->prve = newnode;
			return iterator(newnode);
		}
		iterator  erase(iterator pos)
		{
			assert(pos != end())
				Node* cur = pos._node;
			Node* prve = cur->prve;
			Node* next = cur->next;
			prve->next = next;
			next->prve = prve;
			delete cur;
			return iterator(next);
		}
		void push_back(const T& x)
		{
			insert(end(), x);
		}
		void pop_back()
		{
			erase(--end());
		}
		void push_front(const T& x)
		{
			insert(begin(), x);
		}
		void pop_back()
		{
			erase(begin());
		}
	private:
		Node* _head;
	};
}
